
package ch.hearc.coursJava.GUI.j2D.watch;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;

import ch.hearc.coursJava.GUI.frame.tools.JFrameBase;

public class JFrameWatch extends JFrameBase
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	public JFrameWatch()
		{
		this.panel = new JPanelWatch();
		this.btnStart = new JButton("Start");
		this.btnStop = new JButton("Stop");

		this.btnStart.addActionListener(new ActionListener()
			{

				@Override
				public void actionPerformed(ActionEvent e)
					{
					if (threadIncrement == null)
						{
						threadIncrement = new Thread(panel);
						threadIncrement.start();
						}
					}
			});

		this.btnStop.addActionListener(new ActionListener()
			{

				@Override
				public void actionPerformed(ActionEvent e)
					{
					if (threadIncrement != null && threadIncrement.isAlive())
						{
						threadIncrement.stop();
						threadIncrement = null;
						}
					}
			});

		this.hBox = Box.createVerticalBox();
		this.vBox = Box.createHorizontalBox();

		this.hBox.add(panel);

		this.vBox.add(btnStart);
		this.vBox.add(btnStop);

		this.hBox.add(vBox);
		this.add(hBox);

		this.setPropriete();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/

	// Tools
	private JPanelWatch panel;
	private Thread threadIncrement;

	private JButton btnStart;
	private JButton btnStop;

	private Box hBox;
	private Box vBox;
	}
